function roser_write(filenameroot,dac_r,dac_i,gs_max)
% write the gradients out to disk
filenameroot=[filenameroot '_g' num2str(gs_max)];
ro_file=[filenameroot '_ro.GRD'];
pe_file=[filenameroot '_pe.GRD'];
disp(['writing ' ro_file ' and ' pe_file])
fp_ro = fopen(ro_file,'w');
fp_pe = fopen(pe_file,'w');
for idx=1:size(dac_r,2)
    fprintf(fp_ro,'%d\t1\n',round(dac_r(idx)));
    fprintf(fp_pe,'%d\t1\n',round(dac_i(idx)));
    
end

fclose(fp_ro);
fclose(fp_pe);
end

